'''
Created on Dec 7, 2015

@author: JimmyMo
'''
import unittest
from locator import Locator

class TestLocator(unittest.TestCase):

    def test_LocatorReadFolders(self):
        print(__import__("sys").path)
        print('end...')
        locator = Locator(enabled=True, name='testLocator', locationPath='/home/JimmyMo/git/resourcecare/resourcecare/testres/07.Movies', includeType='_folder_')
        res_iter = locator.do_locate()
        reslist = []
        [reslist.append(elem) for elem in res_iter]
        print("\n".join(reslist))
        self.assertEqual(6, len(reslist))

    def test_LocatorReadFiles4Txt(self):
        locator = Locator(enabled=True, name='testLocator', locationPath='/home/JimmyMo/git/resourcecare/resourcecare/testres/07.Movies', includeType='*.txt')
        res_iter = locator.do_locate()
        reslist = []
        [reslist.append(elem) for elem in res_iter]
        print("\n".join(reslist))
        self.assertEqual(1, len(reslist))
    
    def test_LocatorReadFiles4Mp3AndAvi(self):
        locator = Locator(enabled=True, name='testLocator', locationPath='/home/JimmyMo/git/resourcecare/resourcecare/testres/07.Movies', includeType='*.mp3, *.avi')
        res_iter = locator.do_locate()
        reslist = []
        [reslist.append(elem) for elem in res_iter]
        print("\n".join(reslist))
        self.assertEqual(6, len(reslist))
    
    def test_LocatorReadFiles4CombinedType(self):
        locator = Locator(enabled=True, name='testLocator', locationPath='/home/JimmyMo/git/resourcecare/resourcecare/testres/07.Movies', includeType='*.mp3, a?.avi')
        res_iter = locator.do_locate()
        reslist = []
        [reslist.append(elem) for elem in res_iter]
        print("\n".join(reslist))
        self.assertEqual(4, len(reslist))
        
if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testName']
    unittest.main()